import MonsterBase from './MonsterBase';
import { find_player } from '../../../player/player_class';

export default class Scarecrow extends MonsterBase {
    constructor(entity: GameEntity) {
        super(entity);
    }

    onInit(): void {
        this.entity.mesh = 'mesh/稻草人-2.vb';
        this.skillCount = 1;
        this.findRange = 50;
        this.loseRange = 10;
        this.traceStartRange = { max: this.findRange, min: 5 };
        this.traceStopRange = { max: this.loseRange, min: 3 };
    }

    /**
     * 技能1
     */
    async skill_0() {
        const len = 3;
        for (const e of find_player<GameBounds3>(
            'Gamebound3',
            new GameBounds3(
                this.entity.position.sub(new GameVector3(len, 1, len)),
                this.entity.position.add(new GameVector3(len, 1, len))
            )
        )) {
            if (e.data.hp >= 0) {
                console.log('技能1');
                e.hurt(15, '稻草人');
            }
        }
        await sleep(1000);
    }
}
